<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page language="java" import="com.bluesky.light.admin.*"%>
<%
	request.setCharacterEncoding("UTF-8");
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
	//initization
	session.setAttribute("admin", null);
	
	//login
	String action = request.getParameter("action");
	if (action != null && action.trim().equals("login")) {
		String username = request.getParameter("username");
		String pwd = request.getParameter("pwd");
		Admin admin = Admin.check(username, pwd);
		session.setAttribute("admin", admin);
		
		response.sendRedirect("user_list.jsp");
	}
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>light</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="light,hospital,manage system">
	<meta http-equiv="description" content="light hospital manage system">
	<style type="text/css">
	<!--
	body {
		background: #666666;
		font-family:Verdana, Geneva, sans-serif;
	}
	#header {
		margin:0px;
		margin-top:100px;
	}
	#main {
		height: 300px;
	}
	#logo {
		width:400px;
		margin:auto;
	}
	#login {
		width:400px;
		height:200px;
		margin:auto;	
		background: #e6e6e6;
		padding-left:20px;
		padding-top:20px;
	}
	.login_form {
		width:300px;
		margin:auto;
	}
	-->
	</style>
	
  </head>
  
  <body>
	<div id="header"><div id="logo"><img src="images/logo_small.png" /></div></div>
    <div id="main">
        <div id="login">
            <form action="admin/index.jsp" method="post" class="login_form">
            	<input name="action" value="login" type="hidden"/>
            	<table>
            	<tr>
                <td colspan="2"><h2>Welcome to light</h2></td>
                </tr>
                <tr>
                <td>Admin Name:</td> 
                <td><input type="text" name="username" /></td>
                </tr>
                <tr>
                <td>Password:</td>
                <td><input type="password" name="pwd"/></td>
                </tr>
                <tr>
                <td><input type="image" value="Login" src="images/btn_login.png"/></td>
                </tr>
                </table>
            </form>
        </div>
    </div>
  </body>
</html>
